/********************************************************
Project name: OOP - Home Assignment no. 3

Authors: Rami Berkovsky
         Ofir Cohen

File name: Parser.h

Purpose: Parser for the assembly-like instructions. (declaration only)


********************************************************/

#ifndef _PARSER_H_
#define _PARSER_H_

#include <map>
#include <string>
#include <fstream>
#include "Command.h"

using namespace std;

// Delimeters
#define DEL_START "start"
#define DEL_IF "myif"
#define DEL_ELSE "else"
#define	DEL_ENDLOOP "endloop"
#define DEL_ENDIF "endif"

typedef enum {SUCCESS,FAILURE,EMPTYLINE,ENDLOOP,ELSE,ENDIF} RETURN_VALUE;

//0 == SUCCESS
//1 == FAILURE
//2 == EMPTYLINE
//3 == ENDLOOP
//4 == ELSE
//5 == ENDIF

class Parser {
private:
    static map<const string,const Command*> mapCmd;
public:
	Parser() {};
    ~Parser();                  // Destructs map

    RETURN_VALUE Parse_line(string line, ifstream &fin, string delimeter,Command** cmd);    // process line parsing
	void trimSpaces(string &str);                                   // remove redundant white-spaces
	void split_string(const string &text,vector<string>& words);    // split string into words
	static void GenerateCmdMap();                                   // creates a map of the commands
	bool isNum(const char *s);                                      // returns true/false whether input is a valid num
};

#endif

